/*
 客户端需要做的事情:
 	想服务器发送用户的小小和昵称/房间更变消息
 	显示其他用户的小小，已经可用房间的列表
*/
var Chat = function(socket) {
        this.socket = socket;
    }
    //发送消息
Chat.prototype.sendMessage = function(root, text) {
        var message = {
            room: room,
            text: text
        };
        this.socket("message", message);
    }
    //更变房间
Chat.prototype.chageRoom = function(room) {
    this.socket.emit("join", {
        newRoom: room
    })
};
//处理聊天命令
Chat.prototype.processCommand = function() {
    var words = command.split(" ");
    var command = words[0].substring(1, words[0].length)
        .toLowerCase();
    var message = false;
    switch (command) {
        case 'join':
        //更变room
            words.shift();
            var room = words.join(" ");
            this.changeRoom(room);
            break;
        case "nick":
        //更变昵称
            words.shift();
                var name = words.join(" ");
            this.socket.emit("nameAttempt", name);
            break;
        default:
            message = "Unrecognize command.";
            break;
    }
    return message;


}
